<template>
  <el-button type="primary" style="margin-left: 16px" @click="drawer2 = true">
    with footer
  </el-button>

  <el-drawer v-model="drawerShow" :direction="direction">
    <template #header>
      <h4>{{ drawerTitle }}</h4>
    </template>
    <template #default>
      <div>
        <!-- 显示系统功能树 -->
        <TreeVue></TreeVue>
      </div>
    </template>
    <template #footer>
      <div style="flex: auto">
        <el-button @click="cancelClick">cancel</el-button>
        <el-button type="primary" @click="confirmClick">confirm</el-button>
      </div>
    </template>
  </el-drawer>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessageBox } from 'element-plus'
import TreeVue from './TreeVue.vue'
import { useRolesStore } from '../../stores/roles'
import { storeToRefs } from 'pinia'

const rolesStore = useRolesStore()

const { drawerShow, drawerTitle } = storeToRefs(rolesStore)

const drawer2 = ref(false)
const direction = ref('rtl')
const radio1 = ref('Option 1')

function cancelClick() {
  drawer2.value = false
}
function confirmClick() {
  ElMessageBox.confirm(`Are you confirm to chose ${radio1.value} ?`)
    .then(() => {
      drawer2.value = false
    })
    .catch(() => {
      // catch error
    })
}
</script>
